<template>
  <dialog-box
    :showDialog="showModal"
    width='500px'
    :showHeaderImg="false"
    :headerTitle='$t("nickname")||title'
    :showHeaderTitle='true'
    @onDialogClose='closeModal'
  >
    <div class="content">
      <el-form
        label-position='top'
        @submit.native.prevent
      >
        <el-form-item :label="'昵称'">
          <el-input
            name='owner'
            :value='ownerName'
            :placeholder="'请输入新的昵称'"
          >
          </el-input>
        </el-form-item>
        <button
          style="margin-top: 1px;"
          @click="formSubmit"
          class="btn-block btn-large btn-danger btn-active"
          v-text="$t('submit')||'提交'"
        ></button>
      </el-form>
    </div>
  </dialog-box>
</template>
<script>
export default {
  props: {
    show: {
      type: Boolean,
      default: false
    },
    ownerName: "",
    khyh:''
  },
  data() {
    return {
      showModal: this.show,
      cardNum:"",
      depositBank:"",
      bankBranches: "",
      googleCode: "",
      password: ""
    };
  },
  watch: {
    show: function() {
      this.showModal = this.show;
    }
  },
  methods: {
    formSubmit() {
      if (
        this.owner == "" ||
        this.cardNum == "" ||
        this.depositBank == "" ||
        this.bankBranches == "" ||
        this.password == ""
      ) {
        this.errMsg("请填写完整信息");
        return false;
      }
      if (!this.Util.isBankNo(this.cardNum)) {
        this.errMsg(this.$t("label135") || "银行卡号格式不正确");
        return false;
      }
      this.request(this.api.addbank, {
        hz: this.owner,
        bankcard: this.cardNum,
        bank1: this.depositBank,
        bank2: this.bankBranches,
        // googlecode: this.googleCode,
        googlecode: this.password,
        showLoading: true
      }).then(res => {
        if (res.code == "0") {
          this.successMsg(res.msg || "添加成功");
          this.closeModal();
          this.$emit("bankCardBind");
        } else {
          this.errMsg(res.msg || "添加失败");
        }
      });
    },
    closeModal() {
      this.showModal = false;
      this.$emit("closeModal");
    }
  },
  // mounted(){
  //   this.request(this.api.getuserinfo).then(res=>{
  //         this.cardNum=res.data.userinfo[0].bankcard;
  //         this.depositBank=res.data.userinfo[0].khyh;
  //     })
  // }
};
</script>
<style lang="scss" scoped>
.go-reg {
  color: #b72026;
}
.el-form-item {
  margin-bottom: 20px;
  .code {
    width: 95px;
    border: $default-border;
    margin-left: 15px;
  }
  .mobile-code {
    width: 120px;
    text-align: right;
    right: 15px;
    cursor: pointer;
    &:hover {
      opacity: 0.8;
    }
    &.color-danger {
      color: $color-danger;
    }
  }
}
</style>
